
// to represent nodes in the graph
public class Node {

    // status is used for the visualization of the graph
    // as well as being utilized in back tracking
    // it denotes unchecked and checked nodes and nodes being checked
    String status;
    // this points to the node above this in the graph
    // it points to itself if a wall is above this node
    Node up;
    // this points to the node below this in the graph
    // it points to itself if a wall is below this node
    Node down;
    // this points to the node left of this in the graph
    // it points to itself if a wall is left of this node
    Node left;
    // this points to the node right of this in the graph
    // it points to itself if a wall is right of this node
    Node right;

    // default constructor
    Node() {
        this.status = "empty";
        this.up = this;
        this.down = this;
        this.left = this;
        this.right = this;
    }

    // creates a search tree using this node
    public void initTree(Branch tree, Branch parent) {
        tree.parent = parent;
        tree.data = this;
        if (!this.up.equals(parent.data) && !this.up.equals(this)) {
            Branch newOne = new Branch(this.up);
            this.up.initTree(newOne, tree);
            tree.children.add(newOne);
        }
        if (!this.down.equals(parent.data) && !this.down.equals(this)) {
            Branch newOne = new Branch(this.down);
            this.down.initTree(newOne, tree);
            tree.children.add(newOne);
        }
        if (!this.left.equals(parent.data) && !this.left.equals(this)) {
            Branch newOne = new Branch(this.left);
            this.left.initTree(newOne, tree);
            tree.children.add(newOne);
        }
        if (!this.right.equals(parent.data) && !this.right.equals(this)) {
            Branch newOne = new Branch(this.right);
            this.right.initTree(newOne, tree);
            tree.children.add(newOne);
        }
    }



}
